package com.zhifa.hdtyg_cdgl.service;

import com.alibaba.fastjson.JSONObject;
import com.zhifa.hdtyg_cdgl.dao.SiteUserTestMapper;
import com.zhifa.hdtyg_cdgl.util.HostUtil;
import com.zhifa.hdtyg_cdgl.util.HttpClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class SiteUserTestService {
    @Autowired
    private SiteUserTestMapper siteUserTestMapper;



    public String findNameById(Integer id){
        Map<String, String> param = new HashMap<>();
        param.put("id",String.valueOf(id));
        String s = HttpClientUtil.doGet(HostUtil.UserHost, param);
        JSONObject jsonObject=JSONObject.parseObject(s);

        String username = (String) jsonObject.get("username");
        return  username;
//
//        String nameById = siteUserTestMapper.findNameById(id);
//        return nameById;
    }

    public String findManagerNameById(Integer id){
        Map<String, String> param = new HashMap<>();
        param.put("id",String.valueOf(id));
        String s = HttpClientUtil.doGet(HostUtil.ManagerHost, param);
        JSONObject jsonObject=JSONObject.parseObject(s);
        String username = (String) jsonObject.get("username");
        return  username;
//
//        String nameById = siteUserTestMapper.findNameById(id);
//        return nameById;
    }

}
